package com.anjubao.parking.municipal.roadside.controller;

import com.anjubao.parking.municipal.common.dto.ApiCode;
import com.anjubao.parking.municipal.common.dto.ApiResult;
import com.anjubao.parking.municipal.roadside.dto.RdParkingRecordVo;
import com.anjubao.parking.municipal.roadside.service.ParkingRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/rdParking")
public class RdParkingRecordController {

    @Autowired
    private ParkingRecordService parkingRecordService;

    @GetMapping("/list")
    public ApiResult<List<RdParkingRecordVo>> list(
            @RequestParam(value = "recordType", required = false) Integer recordType,
            @RequestParam(value = "parkingIllegal", required = false) Integer parkingIllegal,
            @RequestParam(value = "page", required = false, defaultValue = "1") int page,
                                             @RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize) {
        ApiResult<List<RdParkingRecordVo>> result = new ApiResult<>(ApiCode.STATUS_OK, parkingRecordService.listParkingRecord(recordType, parkingIllegal,page, pageSize));
        result.setTotal(parkingRecordService.count(recordType, parkingIllegal));
        return result;
    }

    @GetMapping("/{parkingRecordId}/{type}/images")
    public ApiResult<List<String>> listImage(@PathVariable String parkingRecordId,
                                             @PathVariable int type) {
        return ApiResult.success(parkingRecordService.listImages(parkingRecordId, type));
    }

}

